package graphicsExtended.interactive;

import graphicsExtended.templates.abstractClass.Selectable;
import java.awt.event.MouseEvent;

/**
 *
 * @author Shimu
 */
public class TwoButtonInteractiveAnimator extends MouseInteractiveAnimator {

    public TwoButtonInteractiveAnimator(int screenWidth, int screenHeight,
            Selectable... objects) {
        super(screenWidth, screenHeight);
        addSelectables(objects);
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if (e.getButton() == MouseEvent.BUTTON1) { // Left click
            System.out.println("Left click");
            // Deselects everything unless the shift is held down, in which 
            // case even if nothing valid is clicked, the selected objects
            // remain selected (if someone was selecting multiple objects
            // while holding shift, we do not want that person to have all
            // the objects deselected due to an invalid click).
            if (!e.isShiftDown()) {
                selectedObjects.clear();
            }

            // Add the newly selected object
            if (currentSelectable != Selectable.SENTINEL_SELECTABLE) {
                selectedObjects.add(currentSelectable);
                currentSelectable.selected(mouseLocation);
            }

        } else if (e.getButton() == MouseEvent.BUTTON3) { // Right click
            System.out.println("Right click");
            // Notify all the selected objects of the right click
            for (Selectable s : selectedObjects) {
                s.mouseClicked(mouseLocation);
            }
        }

    }

    /* These methods do nothing */
    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void mouseDragged(MouseEvent e) {
    }

}
